package hu.uszeged.inf.wlab.stunner.sync;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;

/**
 * Wrapper service to connect the Android framework with the {@link SyncAdapter}.
 * 
 * @author szelezsant
 */
public class SyncService extends Service {

	/** The {@link SyncAdapter} instance to handle the data sync. */
	private static SyncAdapter syncAdapter = null;

	/** Object used to thread safe locking. */
	private static final Object SYNC_ADAPTER_LOCK = new Object();

	@Override
	public void onCreate() {
		super.onCreate();
		synchronized (SYNC_ADAPTER_LOCK) {
			if (null == syncAdapter) {
				syncAdapter = new SyncAdapter(getApplicationContext(), true);
			}
		}
	}

	@Override
	public IBinder onBind(final Intent intent) {
		return syncAdapter.getSyncAdapterBinder();
	}

}
